
package com.william.killian.trivia.model;

import java.io.Serializable;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;

@Root(name="Answer")
public class Answer implements Serializable
{
    private static final long serialVersionUID = -2176385770258328016L;

    @Text
    private String text;

    @Attribute(required=false)
    private boolean correct;
    
    public Answer () {
        text = "";
        correct = false;
    }
    
    public Answer (String name)
    {
        text = name;
        correct = false;
    }
    
    public boolean isSubmissionCorrect(boolean checked)
    {
        return (correct == checked);
    }
    
    public boolean isCorrect ()
    {
        return correct;
    }

    public String getText ()
    {
        return text;
    }
    
    public String toString ()
    {
        return text;
    }

    public void toggle ()
    {
        correct = !correct;
    }

    public void setName (String string)
    {
        this.text = string;
    }

    public void setCorrect (boolean checked)
    {
        this.correct = checked;
    }
}
